// TI File $Revision: /main/2 $
// Checkin $Date: December 2, 2004   11:50:58 $
//###########################################################################
//
// FILE:	DSP280x_Gpio.c
//
// TITLE:	DSP280x General Purpose I/O Initialization & Support Functions.
//
//###########################################################################
// $TI Release: DSP280x V1.30 $
// $Release Date: February 10, 2006 $
//###########################################################################

#include "DSP280x_Device.h"     // DSP280x Headerfile Include File
#include "DSP280x_Examples.h"   // DSP280x Examples Include File

//---------------------------------------------------------------------------
// InitGpio: 
//---------------------------------------------------------------------------
// This function initializes the Gpio to a known (default) state.
//
// For more details on configuring GPIO's as peripheral functions,
// refer to the individual peripheral examples and/or GPIO setup example. 
void InitGpio(void)
{
   EALLOW;
/*
//   IO0 	- pwm RF
	GpioCtrlRegs.GPAMUX1.bit.GPIO0 = 01;//	dir	1
//   IO1 	- pwm RB
	GpioCtrlRegs.GPAMUX1.bit.GPIO1 = 01;//	dir	1
//   IO2 	- //Sen00      
	GpioCtrlRegs.GPAMUX1.bit.GPIO2 = 00;	//dir	1
//   IO3 	- //Sen00      
	GpioCtrlRegs.GPAMUX1.bit.GPIO3 = 00;	//dir	1

//   IO4 	-  //Sen00     
	GpioCtrlRegs.GPAMUX1.bit.GPIO4 = 00;	//dir	1
//   IO5 	-  //Sen00    
	GpioCtrlRegs.GPAMUX1.bit.GPIO5 = 00;	//dir	1
//   IO6 	- LED0(output io)
	GpioCtrlRegs.GPAMUX1.bit.GPIO6 = 00;	//dir	1
//   IO7 	- SW0(input io)
	GpioCtrlRegs.GPAMUX1.bit.GPIO7 = 00;	//dir	0    -
//   IO8 	- SW1(input io)
	GpioCtrlRegs.GPAMUX1.bit.GPIO8 = 00;	//dir	0   -
//   IO9 	- SW2(input io)
	GpioCtrlRegs.GPAMUX1.bit.GPIO9 = 00;
//   IO10	-  pwm LF      
	GpioCtrlRegs.GPAMUX1.bit.GPIO10 = 01;	//dir	1
//   IO11 - pwm LB      
	GpioCtrlRegs.GPAMUX1.bit.GPIO11 = 01;   //dir		1
	
//   IO12 - Sen01
	GpioCtrlRegs.GPAMUX1.bit.GPIO12 = 00;	//dir	1	-
//   IO13 - Sen00
	GpioCtrlRegs.GPAMUX1.bit.GPIO13 = 00;//	dir	1	-
//   IO14 - VFD DATA      Sen04
	GpioCtrlRegs.GPAMUX1.bit.GPIO14 = 00;//	dir	1	-
//   IO15 - VFD CLOCK     Sen05
	GpioCtrlRegs.GPAMUX1.bit.GPIO15 = 00;//	dir	1	-
	
//mux	0000 0000 / 0101 0000 / 0000 0000 / 0000 0101 */
	GpioCtrlRegs.GPAMUX1.all = 0x00500005;

/*
//   IO16 - spi simo
	GpioCtrlRegs.GPAMUX2.bit.GPIO16 = 01;	//dir	1
//   IO17 - spi so
	GpioCtrlRegs.GPAMUX2.bit.GPIO17 = 01;//	dir	0
//   IO18 - spi clk
	GpioCtrlRegs.GPAMUX2.bit.GPIO18 = 01;//	dir	1
//   IO19 - spi en(output io)
	GpioCtrlRegs.GPAMUX2.bit.GPIO19 = 00;	//dir	1
//   IO20 - qep RA
	GpioCtrlRegs.GPAMUX2.bit.GPIO20 = 01;	//dir	0
//   IO21 - qep RB
	GpioCtrlRegs.GPAMUX2.bit.GPIO21 = 01;	//dir	0
//   IO22 - LED1
	GpioCtrlRegs.GPAMUX2.bit.GPIO22 = 00;	//dir	1
//   IO23 - 
	GpioCtrlRegs.GPAMUX2.bit.GPIO23 = 00;	//dir	1
//   IO24 - qep LA

	GpioCtrlRegs.GPAMUX2.bit.GPIO24 = 10;	//dir	0
//   IO25 - qep LB
	GpioCtrlRegs.GPAMUX2.bit.GPIO25 = 10;	//dir	0
//   IO26 - VFD_RS
	GpioCtrlRegs.GPAMUX2.bit.GPIO26 = 00;//	dir	1
//   IO27 - VFD_DATA
	GpioCtrlRegs.GPAMUX2.bit.GPIO27 = 00;//	dir	1

//   IO28 - rxd
	GpioCtrlRegs.GPAMUX2.bit.GPIO28 = 01;//	dir	0
//   IO29 - txd
	GpioCtrlRegs.GPAMUX2.bit.GPIO29 = 01;	//dir	1
//   IO30 VFD RS      Sen02
	GpioCtrlRegs.GPAMUX2.bit.GPIO30 = 00;	//dir	1
//   IO31 - VFD Sen03
	GpioCtrlRegs.GPAMUX2.bit.GPIO31 = 00;	//dir	1
//mux	0000 0101 / 0000 1010 /  1111 0101 / 0001 0101/ */
	GpioCtrlRegs.GPAMUX2.all = 0x050a0515; 

/*
//   IO32 - vfd_ce(output io)
	GpioCtrlRegs.GPBMUX1.bit.GPIO32 = 00;//	dir	1
//   IO33 - VFD_CLK
	GpioCtrlRegs.GPBMUX1.bit.GPIO33 = 00;//	dir	1
//   IO34  VFD CE   //Sen00     - .nc(input io)
	GpioCtrlRegs.GPBMUX1.bit.GPIO34 = 00;//	dir	1
//mux 	0000 0000 / 0000 0000 / 0000 0000 / 0000 0000/ */
	GpioCtrlRegs.GPBMUX1.all = 0x0;	

/*

	
	GpioCtrlRegs.GPADIR.bit.GPIO0 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO1 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO2 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO3 = 1;

	GpioCtrlRegs.GPADIR.bit.GPIO4 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO5 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO6 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO7 = 0;

	GpioCtrlRegs.GPADIR.bit.GPIO8 = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO9 = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO10 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO11 = 1;

	GpioCtrlRegs.GPADIR.bit.GPIO12 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO13 = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO14 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO15 = 1;

	GpioCtrlRegs.GPADIR.bit.GPIO16 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO17 = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO18 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO19 = 1;

	GpioCtrlRegs.GPADIR.bit.GPIO20 = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO21 = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO22 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO23 = 1;

	GpioCtrlRegs.GPADIR.bit.GPIO24 = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO25 = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO26 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO27 = 1;

	GpioCtrlRegs.GPADIR.bit.GPIO28 = 0;
	GpioCtrlRegs.GPADIR.bit.GPIO29 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO30 = 1;
	GpioCtrlRegs.GPADIR.bit.GPIO31 = 1;*/

	GpioCtrlRegs.GPADIR.all = 0xeccdde7f;

/*
	GpioCtrlRegs.GPBDIR.bit.GPIO32 = 1;
	GpioCtrlRegs.GPBDIR.bit.GPIO33 = 1;
	GpioCtrlRegs.GPBDIR.bit.GPIO34 = 1;
*/
	GpioCtrlRegs.GPBDIR.all = 0x07;

/*

	GpioCtrlRegs.GPAPUD.bit.GPIO20 = 0;    // Enable pull-up for GPIO20 (QEPRA)
	GpioCtrlRegs.GPAPUD.bit.GPIO21 = 0;    // Enable pull-up for GPIO21 (QEPRB)

	GpioCtrlRegs.GPAPUD.bit.GPIO24 = 0;    // Enable pull-up for GPIO24 (QEPLA)
	GpioCtrlRegs.GPAPUD.bit.GPIO25 = 0;    // Enable pull-up for GPIO25 (QEPLB)

	GpioCtrlRegs.GPAPUD.bit.GPIO28 = 0;    // Enable pull-up for GPIO28 (SCIRXDA)
	GpioCtrlRegs.GPAPUD.bit.GPIO29 = 0;    // Enable pull-up for GPIO29 (SCITXDA)
	// 1100 1100 1100 1111 ---*/

	GpioCtrlRegs.GPAPUD.all = 0xCCCFFFFF;    
	GpioCtrlRegs.GPBPUD.all = 0xFFFFFFFF;    // Pullup's disabled GPIO32-GPIO34

	GpioCtrlRegs.GPAQSEL1.all = 0;	//synchronous	
	GpioCtrlRegs.GPAQSEL2.all = 0; //synchronous
	GpioCtrlRegs.GPBQSEL1.all = 0;//synchronous

	EDIS;

}	
	
//===========================================================================
// End of file.
//===========================================================================
